package com.huizu.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.huizu.common.annotation.Log;
import com.huizu.common.core.controller.BaseController;
import com.huizu.common.core.domain.AjaxResult;
import com.huizu.common.enums.BusinessType;
import com.huizu.project.domain.ProUserLdPoints;
import com.huizu.project.service.IProUserLdPointsService;
import com.huizu.common.utils.poi.ExcelUtil;
import com.huizu.common.core.page.TableDataInfo;

/**
 * 用户劳动积分Controller
 * 
 * @author zhangmx
 * @date 2024-05-11
 */
@RestController
@RequestMapping("/project/prouserldpoints")
public class ProUserLdPointsController extends BaseController
{
    @Autowired
    private IProUserLdPointsService proUserLdPointsService;

    /**
     * 查询用户劳动积分列表
     */
    @PreAuthorize("@ss.hasPermi('project:prouserldpoints:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProUserLdPoints proUserLdPoints)
    {
        startPage();
        List<ProUserLdPoints> list = proUserLdPointsService.selectProUserLdPointsList(proUserLdPoints);
        return getDataTable(list);
    }

    /**
     * 导出用户劳动积分列表
     */
    @PreAuthorize("@ss.hasPermi('project:prouserldpoints:export')")
    @Log(title = "用户劳动积分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProUserLdPoints proUserLdPoints)
    {
        List<ProUserLdPoints> list = proUserLdPointsService.selectProUserLdPointsList(proUserLdPoints);
        ExcelUtil<ProUserLdPoints> util = new ExcelUtil<ProUserLdPoints>(ProUserLdPoints.class);
        util.exportExcel(response, list, "用户劳动积分数据");
    }

    /**
     * 获取用户劳动积分详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:prouserldpoints:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(proUserLdPointsService.selectProUserLdPointsById(id));
    }

    /**
     * 新增用户劳动积分
     */
    @PreAuthorize("@ss.hasPermi('project:prouserldpoints:add')")
    @Log(title = "用户劳动积分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProUserLdPoints proUserLdPoints)
    {
        return toAjax(proUserLdPointsService.insertProUserLdPoints(proUserLdPoints));
    }

    /**
     * 修改用户劳动积分
     */
    @PreAuthorize("@ss.hasPermi('project:prouserldpoints:edit')")
    @Log(title = "用户劳动积分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProUserLdPoints proUserLdPoints)
    {
        return toAjax(proUserLdPointsService.updateProUserLdPoints(proUserLdPoints));
    }

    /**
     * 删除用户劳动积分
     */
    @PreAuthorize("@ss.hasPermi('project:prouserldpoints:remove')")
    @Log(title = "用户劳动积分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(proUserLdPointsService.deleteProUserLdPointsByIds(ids));
    }
}
